﻿using System.Collections.Generic;
using System.Linq;
using Fit2ModelsFluent;
using NHibernate;
using System;

namespace Fit2InfrastructureFluent
{
    public class AnswerRepository : IAnswerRepository
    {

        private ISession GetSession()
        {
            var cache = new SessionCache();
            ISession session = cache.GetSession();
            return session;
        }

        public void Save(Answer answer)
        {
            ISession session = GetSession();
            session.SaveOrUpdate(answer);
        }

        public List<Answer> GetAllAnswers()
        {
            throw new NotImplementedException();
        }

        public Answer GetAnswer(Guid AnswerId)
        {
            ISession session = GetSession();
            Answer answer = (Answer)session.Load(typeof(Answer), AnswerId, LockMode.Upgrade);
            return answer;
        }

       
    }
}
